
// F. Chaxel 2010

#ifndef IO_H
#define IO_H

#include "Object.h"

// port defines
#define PORTA 	'A'
#define PORTB 	'B'
#define PORTG 	'G'

//direction defines
#define DIRIN 	'I'
#define DIROUT 	'O'

// pin defines for PORTG
#define PG0	(1<<0)
#define PG1     (1<<1)
#define PG2     (1<<2)
#define PG3     (1<<3)
#define PG4     (1<<4)
#define PG5     (1<<5)
#define PG6     (1<<6)
#define PG7     (1<<7)
#define PG8     (1<<8)
#define PG9     (1<<9)
#define PG10	(1<<10)
#define PG11    (1<<11)
#define PG12    (1<<12)
#define PG13    (1<<13)
#define PG14    (1<<14)
#define PG15    (1<<15)
#define PG16    (1<<16)
#define PG17    (1<<17)
#define PG18    (1<<18)
#define PG19    (1<<19)
#define PG20    (1<<20)
#define PG21    (1<<21)
#define PG22    (1<<22)
#define PG23    (1<<23)
#define PG24    (1<<24)

#define PG8_15	0x00ff00
#define PG16_23	0xff0000


// pin defines for PORTA
#define PA0	(1<<0)
#define PA1	(1<<1)
#define PA2	(1<<2)
#define PA3	(1<<3)
#define PA4	(1<<4)
#define PA5	(1<<5)
#define PA6	(1<<6)
#define PA7	(1<<7)

// pin defines for PORTB
#define PB0	(1<<0)
#define PB1	(1<<1)
#define PB2	(1<<2)
#define PB3	(1<<3)
#define PB4	(1<<4)
#define PB5	(1<<5)
#define PB6	(1<<6)
#define PB7	(1<<7)

class IO:public Object
{
	
	private :
		char PORT;
		int PIN;
		char DIR;

	public:
		IO(unsigned char Port, unsigned int Pin, unsigned char Dir);
		void SetDir(unsigned char Dir);
		void SetOn();
		void SetOff();
		void Toggle();
		bool IsOn();
		bool IsOff();
};

#endif
